11. Make Your Tests Readable

L5 A07 Make Your Tests Readable V2

Assertion Frameworks:

You'll be using Hamcrest in this lesson to write assertions.

Step 1: Add the Hamcrest Dependency

  1. Add the dependency.

app/build.gradle

dependencies {
    // Other dependencies
    testImplementation "org.hamcrest:hamcrest-all:$hamcrestVersion"
}

Step 2: Update your tests so that all of your assertions use Hamcrest.

  1. Update your tests, using the code below as an example.

StatisticsUtilsTest.kt

assertEquals(result.completedTasksPercent, 0f)

// Becomes

assertThat(result.completedTasksPercent, `is`(0f))